﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Data.OleDb;

namespace ConsoleApplication1.DAO
{
    public class Connection
    {
        private static OleDbConnection conn = buildConn();

        private static OleDbConnection buildConn()
        {
            try
            {
                return new OleDbConnection("Provider =Microsoft.Jet.OLEDB.4.0; Data Source =C:\\Users\\victor\\Documents\\Visual Studio 2010\\Projects\\Teste\\TrabalhoIA\\ConsoleApplication1\\base\\base.xls; Extended Properties =Excel 8.0");
            }
            catch (Exception)
            {
                
                throw;
            }
        }

        public static OleDbConnection getConn()
        {
            return conn;
        }

        public static OleDbConnection getCurrentConn()
        {
            try
            {
                if (!conn.State.Equals(System.Data.ConnectionState.Open)) conn.Open();
                return conn;
            }
            catch (Exception)
            {

                throw;
            }
        }

        public void close()
        {
            conn.Close();
        }
    }
}
